const base_URL = 'http://localhost:8080'
const app = getApp();

const request = (option) => {
    return new Promise((resolve, reject) => {
        wx.request({
            url: base_URL + option.url,
            data: option.data || {},
            method: option.method,
            success: (res) => {
                resolve(res)
            },
            fail: (err) => {
                wx.showToast({
                    icon: 'error',
                    title: err.errMsg,
                    mask: true
                })
                reject('fail')
            }
        })
    });
}

export default request